<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title></title>
<!-- 审核意见 -->
<script type="text/javascript">
  var AuditWindow = new Ext.Window({
      el: 'auditWindow',
      width: 400,
      height: 250,
      layout : 'fit',
      closeAction:'hide',
      buttonAlign:'center',
      modal:'true',
      buttons:[{
        text:'确定',
        handler:function(){
         if (AuditWindow.check()){
        	 
      	     var descn = document.getElementById('descn').value;
      	     $.ajax({
    			url: '${ctx}/flow/saveAuditResult.do',
    			type: 'post',
    			dataType: 'json',
    			data: {type : type, flowId : fId, isAgree : agreeVal, descn: descn},
    			success: function(rst, textStatus){
    	  		  if(rst.result == "success"){
    	  			if (type == "1"){
    	  			   window.location = '${ctx}/flow/borrowIndex.do';	
    	  			}  
        	  		if (type == "2"){
     	  			   window.location = '${ctx}/flow/rePayIndex.do';	      	  			
        	  		}
        	  		if (type == "3"){
      	  			   window.location = '${ctx}/flow/reimbIndex.do';	      	  			
         	  		}        	  		
    	  	  	  }else{
    	  	  		AuditWindow.hide();
    	  	  		alert("审核失败，请重试...");
    	  	  	  }
    			}
    	  	 });
      	     AuditWindow.hide();
             AuditWindow.clear();
          }
        }
     }, {text:'取消',
         handler:function(){
           AuditWindow.hide();
           AuditWindow.clear();
         }
     }]
  });
  
  // 清空
  AuditWindow.clear = function() {
    document.getElementById('descn').value = '';
  }
  
  // 检测
  AuditWindow.check = function() {
    var descn = document.getElementById('descn').value;
    if (agreeVal == null || agreeVal == '') {
        Ext.MessageBox.show({
             title:'提示',
             minWidth:220,
             msg:'<div style=\'width:180\';><br/>请选择审核是否通过！</div>',
             buttons:Ext.MessageBox.OK,
             icon:Ext.MessageBox.INFO
        });
        return false;
    }
    if (descn == null || descn == '') {
      Ext.MessageBox.show({
           title:'提示',
           minWidth:220,
           msg:'<div style=\'width:180\';><br/>请填写审核具体意见！</div>',
           buttons:Ext.MessageBox.OK,
           icon:Ext.MessageBox.INFO
      });
      return false;
    }
    return true;
  }
  var agreeVal = null;
  
  function setAgreeValue(aValue) {
	agreeVal = aValue;
  }
  
  var fId = null;
  var type = null;
  function showAuditWindow(flowId, type) {
	this.fId = flowId;
	this.type = type;
	AuditWindow.show();
  }
</script>
</head>
<body>
<!-- 审核 -->
<div id="auditWindow" class="x-hidden">
<div class="x-window-header">审核意见</div>
<div class="x-window-body">
	<table align="center" cellspacing="6">
	  <tr></tr>
	  <tr>
	    <td align="right">是否通过：</td>
	    <td>
	    	<s:radio list="isAgreeMap" id="isAgree" name="isAgree" onchange="setAgreeValue(this.value)" cssStyle="border:0px;"/> 
            <font color="red">*</font>
        </td>
	  </tr>
	  <tr>
	    <td align="right">具体意见：</td>
		<td align="left">
		  <textarea rows="7" name="descn" style="width:280px;" id="descn"></textarea>
		  <font color="red">*</font>
	    </td>
	  </tr>
	</table>
</div>
</div>
</body>